﻿using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel;
using ViewModelInViewModel.Models;

namespace ViewModelInViewModel.ViewModels;

public class MainPageViewModel : ObservableObject {
    public ObservableCollection<InnerViewModel> InnerViewModels { get; }

    public MainPageViewModel() {
        InnerViewModels = new ObservableCollection<InnerViewModel> {
            new(this) {
                Poetry = new Poetry {
                    Id = 1, Name = "Name 1", Content = "Content 1"
                }
            },
            new(this) {
                Poetry = new Poetry {
                    Id = 2, Name = "Name 1", Content = "Content 2"
                }
            },
            new(this) {
                Poetry = new Poetry {
                    Id = 3, Name = "Name 1", Content = "Content 3"
                }
            },
            new(this) {
                Poetry = new Poetry {
                    Id = 4, Name = "Name 1", Content = "Content 4"
                }
            },
            new(this) {
                Poetry = new Poetry {
                    Id = 5, Name = "Name 1", Content = "Content 5"
                }
            },
        };
    }


    public void RemoveInnerViewModel(InnerViewModel innerViewModel) =>
        InnerViewModels.Remove(innerViewModel);
}